<script lang='tsx'>
import { Component } from 'vue-property-decorator';
import ActionTaskActionListViewBase from './action-task-action-list-view-base.vue';

import view_list from '@widgets/action/task-action-list/task-action-list.vue';
@Component({
    components: {
        view_list, 
    },
    beforeRouteEnter: (to: any, from: any, next: any) => {
        next((vm: any) => {
            if(!Object.is(vm.navModel,"route")){
                vm.initNavDataWithTab(vm.viewCacheData);
            }
            vm.$store.commit('addCurPageViewtag', { fullPath: to.fullPath, viewtag: vm.viewtag });
        });
    },
})
export default class ActionTaskActionListView extends ActionTaskActionListViewBase {


    /**
     * 执行created后的逻辑
     *
     * @memberof ActionTaskActionListViewBase
     */
    public afterCreated(){
        let _this:any = this;
        const secondtag = _this.$util.createUUID();
        _this.$store.commit('viewaction/createdView', { viewtag: _this.viewtag, secondtag: secondtag });
        _this.viewtag = secondtag;
        _this.parseViewParam();
        _this.serviceStateEvent = _this.navDataService.serviceState.subscribe(({ action,name, data }:{ action:string,name:any,data:any }) => {
            if(!Object.is(name,'action-task-action-list-view')){
                return;
            }
            if (Object.is(action, 'viewrefresh')) {
                _this.$nextTick(()=>{
                    _this.parseViewParam(data);
                    if(_this.engine){
                        _this.engine.load();
                    }
                });
            }
        });
        if(_this.portletState){
            _this.portletStateEvent = _this.portletState.subscribe((res:any) =>{
                if(!Object.is(res.name,'calendar-view9')){
                    return;
                }
                if(Object.is(res.action,'refresh') && _this.refresh && _this.refresh instanceof Function){
                    _this.refresh();
                }
                if(Object.is(res.action,'getActionData') && res.data){
                    let list:any = this.$refs.list;
                    let appTaskActiondata:any = list.$refs.appTaskActiondata;
                    if(appTaskActiondata && appTaskActiondata.searchActionByTask){
                        appTaskActiondata.searchActionByTask(res.data);
                    }
                }
            })
        }

    }

}
</script>